import { createStore } from 'vuex';

const store = createStore({
  state: {
    loading: false, // 全局 loading 状态
  },
  mutations: {
    setLoading(state, value) {
      state.loading = value; // 修改 loading 状态
    },
  },
  actions: {
    startLoading({ commit }) {
      commit('setLoading', true); // 启动加载
    },
    stopLoading({ commit }) {
      commit('setLoading', false); // 停止加载
    },
  },
});

export default store;
